﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Mvc;
//using WaterQAdmin.Website.Common;
//using WaterQAdmin.Website.Models;
//using WaterQAdmin.Website.Business;
using Newtonsoft.Json;

namespace Mysoft.Rpa.ControlWeb.Controllers
{
    public class HomeController : BaseController
    {
        //[Route("/Login")]
        //public IActionResult Login(bool logout)
        //{
        //    if (logout)
        //    {
        //        Auth.SignOut(HttpContext);
        //    }
        //    ViewBag.WebsiteName = AppSettings.WebConfig.Name;
        //    return View();
        //}

        //[HttpPost]
        //[Route("/CheckLogin")]
        //public JsonResult CheckLogin(string username, string password)
        //{
        //    if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
        //    {
        //        return JsonResult(ReturnCode.ParamError.Code, "请求参数错误，不能为空");
        //    }

        //    var tuple = new AdminUserBiz().CheckLogin(username, password);
        //    if (tuple.Item1 == ReturnCode.Success.Code)
        //    {
        //        LoginUserInfo userinfo = new LoginUserInfo
        //        {
        //            AdminID = tuple.Item3.AdminUserID,
        //            Username = tuple.Item3.Username,
        //            UserType = tuple.Item3.Username.ToLower() == "admin" ? UserType.Admin : UserType.User,
        //            LoginTime = DateTime.Now
        //        };
        //        Auth.SignIn(HttpContext, userinfo);
        //    }
        //    LogHelper.Info("CheckLogin Result=" + JsonConvert.SerializeObject(tuple));
        //    return JsonResult(tuple.Item1, tuple.Item2);
        //}

        [HttpGet]
        [Route("/Main")]
        public IActionResult Main()
        {
            //var UserInfo = Auth.GetUserInfo(HttpContext);
            //ViewBag.UserInfo = UserInfo;
            //ViewBag.WebsiteName = AppSettings.WebConfig.Name;
            return View();
        }

        public IActionResult Welcome()
        {
            return View();
        }

        //[HttpGet]
        //[HttpPost]
        //public IActionResult ModifyPwd(ModifyPassModel model)
        //{
        //    var UserInfo = Auth.GetUserInfo(HttpContext);
        //    ViewBag.UserInfo = UserInfo;

        //    if (HttpContext.Request.Method.ToUpper() == "GET")
        //        return View();

        //    var tuple = new AdminUserBiz().ModifyPassword(UserInfo.AdminID, model.OldPwd, model.NewPwd);
        //    return JsonResult(tuple);
        //}
    }
}